<?php

namespace App\Admin\Controllers;

use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use \App\Models\PayConfig;

class PayConfigsPicController extends AdminController
{
    protected $title = '相由心生支付配置';
    
    protected function grid()
    {
        $grid = new Grid(new PayConfig());
        $grid->model()->where("type",1);
	    $grid->disableExport();
	
	    $grid->column('id', 'ID');
	    $grid->column('name', '支付配置的名称');
	    $grid->column('desc', '支付配置的描述');
	    $grid->column('price', '价格');
	    $grid->column('pic_num', '图片单次起卦次数');
	    $grid->column('pic_merge_num', '图片合图起卦次数');
	   
	    $grid->column('created_at', '创建时间')->display(function () {
		    return $this->created_at->toDatetimeString();
	    });
	
	    $grid->disableRowSelector();

        return $grid;
    }
	
	 protected function detail($id)
    {
        $show = new Show(PayConfig::findOrFail($id));
        return $show;
    }
	
    protected function form()
    {
        $form = new Form(new PayConfig());

	    $form->text('name', '支付配置的名称')->rules('required');
	    $form->text('desc', '支付配置的描述')->rules('required');
	    $form->currency('price', '价格')->symbol('￥')->rules('required|numeric');
	    $form->hidden('status')->value("times");
	    $form->hidden('type')->value("1");
	    $form->number('pic_num', '图片单次起卦次数')->rules('required|numeric');
	    $form->number('pic_merge_num', '图片合图起卦次数')->rules('required|numeric');
	    
        return $form;
    }
}
